package com.lzy.business.response.excel;

import com.lzy.framework.core.excel.annotation.ExcelColumn;
import com.lzy.framework.core.utils.StringUtil;
import com.lzy.product.constants.AgentOrderEnum;

import java.math.BigDecimal;

public class AgentOrderReponse {
    /**
     * 协议信息
     */
    @ExcelColumn(value = "协议信息", sort = 0, width = 256 * 15)
    private String protocolName;
    /**
     * 签约人
     */
    @ExcelColumn(value = "签约人", sort = 1, width = 256 * 25)
    private String name;
    /**
     * 签约时间
     */
    @ExcelColumn(value = "签约时间", sort = 2, width = 256 * 20)
    private String createTime;
    /**
     * 签约金额
     */
    @ExcelColumn(value = "签约金额", sort = 3, width = 256 * 15)
    private BigDecimal salePrice;
    /**
     * 订单状态
     */
    @ExcelColumn(value = "订单状态", sort = 4, width = 256 * 20)
    private String status;

    /**
     * 手机号
     */
    private String phone;

    public String getPhone() {
        return phone;
    }

    public void setPhone(String phone) {
        this.phone = phone;
    }

    public String getProtocolName() {
        return protocolName;
    }

    public void setProtocolName(String protocolName) {
        this.protocolName = protocolName;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getCreateTime() {
        return createTime;
    }

    public void setCreateTime(String createTime) {
        if (!StringUtil.isBlank(createTime) && createTime.substring(createTime.length() - 2, createTime.length()).equals(".0")) {
            this.createTime = createTime.substring(0, createTime.length() - 2);
        } else
            this.createTime = createTime;
    }

    public BigDecimal getSalePrice() {
        return salePrice;
    }

    public void setSalePrice(BigDecimal salePrice) {
        this.salePrice = salePrice;
    }

    public String getStatus() {
        return status;
    }

    public void setStatus(String status) {
        this.status = getStatusNameByKey(status);
    }

    /**
     * 根据订单状态枚举key取得value
     *
     * @param k
     * @return
     */
    private String getStatusNameByKey(String k) {
        AgentOrderEnum.OrderStatus orderStatus[] = AgentOrderEnum.OrderStatus.values();
        for (AgentOrderEnum.OrderStatus orderStatus1 : orderStatus) {
            if (orderStatus1.getCode().toString().equals(k)) {
                return orderStatus1.getDesc();
            }
        }
        return null;
    }

}
